package com.ruoyi.dash.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dash.domain.TbPartyBuilding;
import com.ruoyi.dash.service.ITbPartyBuildingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 党建Controller
 * 
 * @author ruoyi
 * @date 2025-10-25
 */
@RestController
@RequestMapping("/dash/building")
public class TbPartyBuildingController extends BaseController
{
    @Autowired
    private ITbPartyBuildingService tbPartyBuildingService;

    /**
     * 查询党建列表
     */
    @PreAuthorize("@ss.hasPermi('dash:building:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbPartyBuilding tbPartyBuilding)
    {
        startPage();
        List<TbPartyBuilding> list = tbPartyBuildingService.selectTbPartyBuildingList(tbPartyBuilding);
        return getDataTable(list);
    }

    /**
     * 导出党建列表
     */
    @PreAuthorize("@ss.hasPermi('dash:building:export')")
    @Log(title = "党建", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbPartyBuilding tbPartyBuilding)
    {
        List<TbPartyBuilding> list = tbPartyBuildingService.selectTbPartyBuildingList(tbPartyBuilding);
        ExcelUtil<TbPartyBuilding> util = new ExcelUtil<TbPartyBuilding>(TbPartyBuilding.class);
        util.exportExcel(response, list, "党建数据");
    }

    /**
     * 获取党建详细信息
     */
    @PreAuthorize("@ss.hasPermi('dash:building:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbPartyBuildingService.selectTbPartyBuildingById(id));
    }

    /**
     * 新增党建
     */
    @PreAuthorize("@ss.hasPermi('dash:building:add')")
    @Log(title = "党建", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbPartyBuilding tbPartyBuilding)
    {
        return toAjax(tbPartyBuildingService.insertTbPartyBuilding(tbPartyBuilding));
    }

    /**
     * 修改党建
     */
    @PreAuthorize("@ss.hasPermi('dash:building:edit')")
    @Log(title = "党建", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbPartyBuilding tbPartyBuilding)
    {
        return toAjax(tbPartyBuildingService.updateTbPartyBuilding(tbPartyBuilding));
    }

    /**
     * 删除党建
     */
    @PreAuthorize("@ss.hasPermi('dash:building:remove')")
    @Log(title = "党建", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbPartyBuildingService.deleteTbPartyBuildingByIds(ids));
    }
}
